package com.wsd.web;

import com.alibaba.fastjson.JSONObject;
import com.wsd.common.CardOCR;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * @author wjh
 */
@Controller
public class OCRController {

    @RequestMapping("/cardOCRTest")
    public String cardOCRTest() {
        return "ocr";
    }

    @ResponseBody
    @RequestMapping(value = "/idCardOCR", method = RequestMethod.POST)
    public JSONObject idCardOCR(HttpServletRequest request) {
        String idCardBase64 = request.getParameter("idCardBase64");
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("idcard", CardOCR.idCardOCR(idCardBase64));
        return jsonObject;
    }

    @ResponseBody
    @RequestMapping(value = "/bankCardOCR", method = RequestMethod.POST)
    public JSONObject bankCardOCR(HttpServletRequest request) {
        String bankCardBase64 = request.getParameter("bankCardBase64");
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("bankcard", CardOCR.bankCardOCR(bankCardBase64));
        return jsonObject;
    }

}
